import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter)

// 全局解决路由跳转的小BUG  第二种
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

// 引入路由组件
import Home from '@/pages/Home'
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
export default new VueRouter({
    routes: [
        { 
            name: 'home',
            path: '/home',
            component:Home
        },
        { 
            name:'search',
            path: '/search',
            component:Search
        },
        { 
            name:'login',
            path: '/login',
            component:Login
        },
        { 
            path: '/register',
            component:Register
        },
        {
            path:'/',
            redirect:'/home'
        }
    ]
})